﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using Mvc.XForms.Examples.Controllers;
using Mvc.XForms.Controls.Formatters;
using StructureMap;

namespace Mvc.XForms.Examples {
	public class MvcApplication : System.Web.HttpApplication {
		public static void RegisterRoutes(RouteCollection routes) {
			routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

			routes.MapRoute(
				"Default",                                              // Route name
				"{controller}/{action}",                           // URL with parameters
				new { controller = "Customer", action = "List" }  // Parameter defaults
			);
		}

		protected void Application_Start() {
			RegisterRoutes(RouteTable.Routes);
			ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
			ObjectFactory.Initialize(x => {
				x.AddRegistry(new WebRegistry());
			});

			// Use the following to override XForms formatting
			//FormatterFactory.Current.Formatter = new ExampleFormatter();
		}
	}
}